var User = require('../user')
var Activity = require('../activity')
var user = require('../user');
var WeiXinApi = require('../../lib/WeiXinApi');
var needle = require('needle');
var InitRedisCache = require('../../lib/InitRedisCache');
var needle = require('needle');

function test(){
    /*user.newAndSave('董斐^_^快乐邦',
        'female',
        '朝阳',
        '北京',
        '中国',
        'otO6QjjtyxiFm8vDjJgWMaepsUwM',
        'http://wx.qlogo.cn/mmopen/ajNVdqHZLLCwrChYv2fLgAK1vtI8OnD8LvicWXtsRbC44REv5GDevOJneCOh5GEf0ibqo4wUVHwRBk0bbnZBjxug/0',
        function(err, data){
            if(err) console.log(err)
            console.log(data)
        })*/
    /*user.newAndSave('教父右手',
        'male',
        '朝阳',
        '北京',
        '中国',
        'oi4U0uEtt63r-S767f-rgx4tNBjs',
        'http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46',
        function(err, data){
        if(err) console.log(err)
        console.log(data)
    })*/
   /* WeiXinApi.getUserInfo('n-OjNzPyDuloj7sZR9AnmkUA3ppHPmRP18y_wk5cGUue-01GVP6hqMy1U2yAMjuDD8TMh5snpUVfwji6SZRQRQ',
        'oi4U0uEtt63r-S767f-rgx4tNBjs', function(err, data){
            user.newAndSave()
    })*/
    /*var option = {headers: {'Content-Type': 'application/json'}, decode:false}
    var url = 'https://api.weixin.qq.com/sns/userinfo?access_token=OezXcEiiBSKSxW0eoylIeENZnvOMTbJgQOWr-WmE7dxw9pyu-esqcrk4R2ERBCVOyx86FAF1ODpKU8pr1lkYA8Rd_yePTdMq8IhHolLQAXtd7sCyWARI_vkQDPvLuFCgfguVUFZc1ZiwifLYHlWbxw&openid=oi4U0uN8Ag4_tOF9W8S4vbhRaZvM&lang=zh_CN';
    needle.get(url, option, function(err, resp, body){
        console.log(JSON.parse(body))
    })*/

    //InitRedisCache.initFactionMembers();
    var options = {
        headers:{
            'Content-Type':'application/json'
        }
    }
    var accessToken = 'KuTs4IzgIdqg0Lb5s_WREctPzN70n1PRC7XnGkCxtof1i8HDfjRXgdgkz_TpAzJT_QnU3o1tt-p9Fzg_PUnX6OnioZd92GNav2yDIevJzRg';
    var url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+accessToken;
    var postdata = JSON.stringify({ touser: 'oWvNpuP0jhcQvpOYi_Tq-dBExa74',
        template_id: 'XHSPe829YV_yIC4tjV5QVsnLJcBC9Q4-3kfvjI9BEn4',
        url: 'http://wechatjh.fourjoy.net/user/',
        topcolor: '#44B549',
        data:
        { first: { value: '好友[教父右手]通过你分享的链接抢到了快乐镑，分你一半哟~以后继续分享哈~(≧▽≦)/~' },
            time: { value: '2014-11-07' },
            account: { value: '教父右手#3585', color: '#173177' },
            type: { value: '签到抢快乐镑' },
            creditChange: { value: '本次快乐镑', color: '#173177' },
            number: { value: 60, color: '#173177' },
            creditName: { value: '卧槽快乐镑', color: '#173177' },
            amount: { value: 630, color: '#173177' },
            remark: '点击查看我的账户余额' } });
    needle.post(url, postdata, options, function cb(err,resp,body){
        console.log(err);
        console.log(body);
    });
}

test()